package com.jinunn.hosp.controller.home;

import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import com.jinunn.common.result.Result;
import com.jinunn.hosp.service.HospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author JinDnn
 * @date 2021/5/9 23:28
 */

@Api(tags = "前台页面")
@RestController
@RequestMapping("/api/hosp/hospital")
public class HospApiController {

    @Autowired
    private HospitalService hospitalService;

    @ApiOperation(value = "查询医院列表")
    @GetMapping("findHospList/{page}/{limit}")
    public Result<Page<Hospital>> findHospList(@PathVariable("page") Integer page,
                                               @PathVariable("limit") Integer limit,
                                               @RequestBody(required = false) HospitalQueryVo hospitalQueryVo){
        Page<Hospital> hospitalList = hospitalService.seleteHospPage(page, limit, hospitalQueryVo);
        return Result.ok(hospitalList);
    }

    @ApiOperation("根据医院名称模糊查询")
    @GetMapping("findHospName/{hospName}")
    public Result<List<Hospital>> findHospName(@PathVariable("hospName") String hospName){
       List<Hospital> list = hospitalService.findHospName(hospName);
        return Result.ok(list);
    }
}
